﻿using System.Collections.Generic;
using System.IO;
using System.Text;
namespace CharpClassGen
{
    public static class Helper
    {
        public  static string Retract(int retract)
        {
            return new string('\t', retract);
        }
        public static void AddMuitLineToStringBuilder(StringBuilder sb, List<string> codeBlock, int retrat)
        {
            foreach (var item in codeBlock)
            {
                string[] lines = item.Split("\n");
                foreach (var line in lines)
                {
                    if (!string.IsNullOrWhiteSpace(line))
                    {
                        sb.AppendLine($"{Retract(retrat)}{line.Replace("\r", "")}");
                    }
                }
            }
        }
        public static bool PropTypeIsCollection(string propType)
        {
            if (
                    propType.StartsWith("List<") ||
                    propType.StartsWith("Dictionary<") ||
                    propType.StartsWith("Queue<") ||
                    propType.StartsWith("Stack<"))
            {
                return true;
            }
            return false;
        }

        public static void CheckAndCreatDir(string genDir)
        {
            if (!Directory.Exists(genDir))
            {
                Directory.CreateDirectory(genDir);
            }
        }
    }
}



